﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Collections;

namespace ShoppingCart
{
    class Program
    {
        static void Main(string[] args)
        {
            ArrayList al = new ArrayList();
            al.Add(new ShoppingCartItem("Pringles", 6.50));
            al.Add(new ShoppingCartItem("Skate", 55.30));
            al.Add(new ShoppingCartItem("Smoking", 155.31));
            al.Add(new ShoppingCartItem("Ferrari GT", 303155.00));

            al.Sort();
            al.Reverse();

            foreach (ShoppingCartItem item in al)
                Console.WriteLine(item.itemName + " - " + item.price.ToString());

            Console.Read();
        }

        class ShoppingCartItem : IComparable
        {
            public string itemName;
            public double price;

            public ShoppingCartItem(string itemName, double price)
            {
                this.itemName = itemName;
                this.price = price;
            }

            #region IComparable Members

            public int CompareTo(object obj)
            {
                ShoppingCartItem otherItem = (ShoppingCartItem)obj;
                return (this.price.CompareTo(otherItem.price));
            }

            #endregion
        }
    }
}
